<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // fetch('http://localhost:3000/home').then(res => {
        //     return res.json()
        // }).then(data => {
        //     console.log(data)
        // })//会跨域

        window.callback = function(res) { // 回调函数
            console.log(res)
        }

        const script = document.createElement('script')
        script.src="http://localhost:3000/home?cd='callback'"//'callback({"name":"zhangsan"})'
        document.body.appendChild(script) // 动态创建script标签,同源策略不工作，不会跨域

    </script>
    
</body>
</html>